import { Connection } from '../constant';

export default function reducer(state = {
    isVisible: false,
    isLoading: false,
    form: {} }, action) {

    let {type, data} = action;

    if (Connection.VISIBLE === type) return {...state, isVisible: data};
    if (Connection.LOADING === type) return {...state, isLoading: data};
    if (Connection.OPEN === type) return {...state, isLoading: false, isVisible: true, form: data};
    if (Connection.SETFORM === type) return {...state, form: data};

    return state;
}